/**
 * Copyright (c) 2014 zhenrongbao.com, Inc. All Rights Reserved
 * @author: jiangshuguang
 * @Date  : 14-10-10
 * @Time  : 下午3:21
 * @brief :
 */
exports.registerguide = function(){
    var ShareTip = require("wap_common:widget/ui/sharetip/sharetip.js").ShareTip,
        util = require("wap_common:widget/ui/libs/util.js").util,
        $page = $(".widget-register-guide"),
        $tip = $page.find(".tip"),
        $username = $page.find(".phone"),
        $phoneBtn = $page.find(".btn-phone"),
        $btnShare = $page.find(".btn-share"),
        shareTip = new ShareTip();

    function tipShow(text){
        $tip.css("visibility","visible").text(text);
    }

    $phoneBtn.on("click",function(){
        if(!($(this).hasClass("btn-disable"))){
            var username = $.trim($username.val());
            if(util.checkPhone(username)){
                location.href="/activity/register?" +
                    "open_id="+$(this).attr("data-open-id")+
                    "&phone="+username+
                    "&register_from="+$(this).attr("data-register-from")
            }else{
                tipShow("手机号码输入错误");
            }
        }
    });

    $page.find(".to-baidu").click(function(){
        location.href="http://www.baidu.com/from=844b/s?word=%E7%9C%9F%E8%9E%8D%E5%AE%9D&ts=7087458&t_kt=22&sa=ihr_1&ms=1&ss=001"
    });

    $page.find(".share-guide").on("touchmove",function(e){
        e.preventDefault();
    }).on("click",function(){
            $(this).hide();
        });

    $btnShare.on("click",function(){
        shareTip.showShare();
    });

    P.share.on('send',function(res){
        ShareTip.hide();
    });
};